﻿@{
    Page.Title = "Home";

    var db = Database.Open("bakery");
    var products = db.Query("SELECT * FROM PRODUCTS").ToList();
    var featured = products[new Random().Next(products.Count)];
}

<h1>Welcome to Fourth Coffee!</h1>
<p>
    This sample site showcases the Disqus helper. To see the helper in action, follow these steps:
    <ol>
        <li>Create an account at <a href="http://disqus.com/">Disqus</a> and make note of your website shortname.</li>
        <li>Uncomment the Disqus.Initialize() method in the <strong>_AppStart.cshtml</strong> file of this site, and replace the placeholder with your website shortname.</li>
        <li>Click the Order Now button.</li>
    </ol>
</p>
<div id="featuredProduct">
    <img alt="Featured Product" src="@Href("~/Images/Products/" + featured.ImageName)" />
    <div id="featuredProductInfo">
        <div id="productInfo">
            <h2>@featured.Name</h2>
            <p class="price">$@string.Format("{0:f}", featured.Price)</p>
            <p class="description">@featured.Description</p>
        </div>
        <div id="callToAction">
            <a class="order-button" href="@Href("~/order", featured.Id)" title="Order @featured.Name">Order Now</a>
        </div>
    </div>
</div>

<ul id="products">
    @foreach (var p in products) {
        <li class="product">
            <div class="productInfo">
                <h3>@p.Name</h3>
                <img class="product-image" src="@Href("~/Images/Products/Thumbnails/"+ p.ImageName)" alt="Image of @p.Name" />
                <p class="description">@p.Description</p>                    
            </div>
            <div class="action">
                <p class="price">$@string.Format("{0:f}", p.Price)</p>
                <a class="order-button" href="@Href("~/order", p.Id)" title="Order @p.Name">Order Now</a>
            </div>
        </li>
    }
</ul>